// http://poj.org/problem?id=3984

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int SIZE = 5;
int arr[SIZE][SIZE];
int ans[25][2];
int idx = 0;
int forwards[4][2] = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1}
};

int visited[SIZE][SIZE];
bool found = false;

void dfs(const int x, const int y) {
    if (found) {
        return;
    }

    visited[x][y] = 1;
    ans[idx][0] = x, ans[idx][1] = y;
    idx++;

    if (x == SIZE-1 && y == SIZE-1) {
        found = true;
        return;
    }

    for (int i = 0; i < 4; i++) {
        const int nx = forwards[i][0] + x;
        const int ny = forwards[i][1] + y;
        if (nx >= SIZE || ny >= SIZE || nx < 0 || ny < 0 || visited[nx][ny] || arr[nx][ny] == 1) {
            continue;
        }
        dfs(nx, ny);
        if (found) {
            return;
        }
    }
    idx--;
}


int main() {
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            scanf("%d", &arr[i][j]);
        }
    }

    // DFS
    dfs(0, 0);
    for (int i = 0; i < idx; i++) {
        printf("(%d, %d)\n", ans[i][0], ans[i][1]);
    }
    return 0;
}

/*
0 1 0 0 0
0 1 0 1 0
0 0 0 0 0
0 1 1 1 0
0 0 0 1 0
*/